<?php $this->_extends('_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>

<link href="<?php echo $_BASE_DIR; ?>plugins/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>plugins/xheditor/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>plugins/xheditor/xheditor-1.1.11-zh-cn.min.js "></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>plugins/uploadify/swfobject.js"></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>plugins/uploadify/jquery.uploadify.v2.1.4.min.js"></script>

<form action="<?php echo url('vote/Edit'); ?>" method="post" name="mainform"enctype="multipart/form-data"
        onsubmit="
        if (this.vote_topic.value == '') 
        { 
	    alert('请输入投票标题'); 
	    return false; 
        }
        else if(this.vote_topic.value.length > 256)
        {
            alert('投票标题不能超过256个字符');
            return false;
        }
        else if(this.summary.value.length > 1024)
        {
            alert('投票摘要不能超过1024个字符');
            return false;
        }
        else
        {
            var content = editor.getSource();
            if (content == '')
            {
                alert('请输入文章内容');
                return false;
            }
            var images = $('img', content);
            if(images.length > 0)
            {
                this.content_image.value = images[0].src;
            }
        }
	return true;"
>
    <label><h5>投票标题</h5></label>
    文章标题最好小于12个汉字，或者个24个英文字符，否则影响客户端显示效果</br>
    <input class="input" type="text" value="<?php echo $vote->vote_name; ?>"  name="vote_name" size="60%" width="400"></input>

    <label><h5>投票摘要</h5></label>
    <textarea name="summary" rows=5 cols=78 >
    <?php echo $vote->vote_summary; ?>
    </textarea>

    <div name="vote_logo" id="vote_logo">
    <label><h5>标题图片</h5></label>
    <input id="file_upload" type="file" name="Filedata" /> </p>
    <div id="filesUploaded" name="filesUploaded"> 
    <img src="<?php echo $vote->vote_icon; ?>" style="max-width:300px;">
    </div>

<script type="text/javascript">
$(function() {
    $('#file_upload').uploadify({
        'uploader'  : '<?php echo $_BASE_DIR; ?>plugins/uploadify/uploadify.swf',
            'script'    : '<?php echo $_BASE_DIR; ?>plugins/uploadify/uploadify.php',
            'cancelImg' : '<?php echo $_BASE_DIR; ?>plugins/uploadify/cancel.png',
            'folder'    : '<?php echo $upload_dir; ?>',
            'removeCompleted' : true,
            'fileDesc'  : '图片文件',
            'fileExt'   : '*.jpg;*.bmp;*.png;*.gif',
            'sizeLimit' : 1024 * 1024 * 2,
            'onComplete': function(event, queueID, fileObj, response, data) 
        {
            while(filesUploaded.firstChild)
            {
                var oldNode = filesUploaded.removeChild(filesUploaded.firstChild);
                oldNode = null;
            }
            $('#filesUploaded').append('<img src='+response+' style="max-width:300px;"><input type=hidden value='+response+' name=uploadpic />');
        }
    }); });
    </script>
    <a href="javascript:$('#file_upload').uploadifyUpload()">上传</a>
    </div>
    <div>
    <label><h5>投票选项</h5></label>
    <table cellpadding="0" id="ParamConf" name="ParamConf" cellspacing="0" width="100%">
    <tbody class="">

    <?php foreach($options as $option): ?>
    <label><?php echo $option->option_content; ?> </label> </br>
    <?php endforeach; ?>
    
    <?php if($vote->vote_type == 1): ?>
        <label><h5>多项选择</h5></label> </br>
    <?php else: ?>
        <label><h5>单项选择</h5></label> </br>
    <?php endif; ?>

    <!-- label><h5>投票内容</h5></label>
    <textarea id="content" name="content" cols="65" rows="15" 
    class="xheditor {width:'600', height:'400', urlType:'abs', upLinkUrl:'upload.php?immediate=1', upImgUrl:'upload.php?immediate=1', upFlashUrl:'upload.php?immediate=1', upMediaUrl:'upload.php?immediate=1'}"><?php echo $vote->vote_content; ?></textarea --!>
    <input type="hidden" value=" " name="content" />
    <input type="hidden" value="<?php echo $vote->vote_id; ?>" name="vote_id" id="<?php echo $vote->vote_id; ?>" />
    <input type="submit" value="提交审核" name="submit">
    </form>

<?php $this->_endblock(); ?>
